//
//  RectButton.m
//  CloudWeibo
//
//  Created by CLOUD on 1/15/15.
//  Copyright (c) 2015 Cloud. All rights reserved.
//

#import "RectButton.h"

@implementation RectButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
    if (_title != title) {
        [_title release];
        _title = [title copy];
    }
    
    [self setTitle:nil forState:UIControlStateNormal];
    
    if (_rectTitleLabel == nil) {
        _rectTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, 60, 20)];
        _rectTitleLabel.backgroundColor = [UIColor clearColor];
        _rectTitleLabel.font = [UIFont systemFontOfSize:18.0f];
        _rectTitleLabel.textColor = [UIColor blackColor];
        _rectTitleLabel.textAlignment = NSTextAlignmentCenter;
        _rectTitleLabel.text = title;
        [self addSubview:_rectTitleLabel];
    }
}

- (void)setSubTitle:(NSString *)subTitle
{
    if (_subTitle != subTitle) {
        [_subTitle release];
        _subTitle = [subTitle copy];
    }
    
    [self setTitle:nil forState:UIControlStateNormal];
    
    if (_subTitleLabel == nil) {
        _subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 25, 60, 20)];
        _subTitleLabel.backgroundColor = [UIColor clearColor];
        _subTitleLabel.font = [UIFont systemFontOfSize:18.0f];
        _subTitleLabel.textColor = [UIColor blackColor];
        _subTitleLabel.textAlignment = NSTextAlignmentCenter;
        _subTitleLabel.text = subTitle;
        [self addSubview:_subTitleLabel];
    }
}

@end
